/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "userroles")
@NamedQueries({@NamedQuery(name = "UserRole.findByUserRoleId", query = "SELECT u FROM UserRole u WHERE u.userRoleId = :userRoleId"), @NamedQuery(name = "UserRole.findByUserRoleDescription", query = "SELECT u FROM UserRole u WHERE u.userRoleDescription = :userRoleDescription")})
public class UserRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "userRoleId", nullable = false)
    private Integer userRoleId;
    @Column(name = "userRoleDescription")
    private String userRoleDescription;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userRoleId")
    private Collection<UserPrivilage> userprivilagesCollection;

    public UserRole() {
    }

    public UserRole(Integer userRoleId) {
        this.userRoleId = userRoleId;
    }

    public Integer getUserRoleId() {
        return userRoleId;
    }

    public void setUserRoleId(Integer userRoleId) {
        this.userRoleId = userRoleId;
    }

    public String getUserRoleDescription() {
        return userRoleDescription;
    }

    public void setUserRoleDescription(String userRoleDescription) {
        this.userRoleDescription = userRoleDescription;
    }

    public Collection<UserPrivilage> getUserprivilagesCollection() {
        return userprivilagesCollection;
    }

    public void setUserprivilagesCollection(Collection<UserPrivilage> userprivilagesCollection) {
        this.userprivilagesCollection = userprivilagesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userRoleId != null ? userRoleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserRole)) {
            return false;
        }
        UserRole other = (UserRole) object;
        if ((this.userRoleId == null && other.userRoleId != null) || (this.userRoleId != null && !this.userRoleId.equals(other.userRoleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.UserRole[userRoleId=" + userRoleId + "]";
    }

}
